Public Class MClient
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtMSG As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtTimes As System.Windows.Forms.TextBox
    Friend WithEvents BtnSend As System.Windows.Forms.Button
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents btnSendN As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.txtMSG = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtTimes = New System.Windows.Forms.TextBox
        Me.btnSendN = New System.Windows.Forms.Button
        Me.BtnSend = New System.Windows.Forms.Button
        Me.Label3 = New System.Windows.Forms.Label
        Me.txtName = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 72)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(136, 16)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Msg:"
        '
        'txtMSG
        '
        Me.txtMSG.Location = New System.Drawing.Point(16, 96)
        Me.txtMSG.Multiline = True
        Me.txtMSG.Name = "txtMSG"
        Me.txtMSG.ScrollBars = System.Windows.Forms.ScrollBars.Both
        Me.txtMSG.Size = New System.Drawing.Size(416, 104)
        Me.txtMSG.TabIndex = 1
        Me.txtMSG.Text = "1234567890"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 280)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 24)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "Times"
        '
        'txtTimes
        '
        Me.txtTimes.Location = New System.Drawing.Point(144, 280)
        Me.txtTimes.Name = "txtTimes"
        Me.txtTimes.Size = New System.Drawing.Size(128, 22)
        Me.txtTimes.TabIndex = 3
        Me.txtTimes.Text = "100000"
        '
        'btnSendN
        '
        Me.btnSendN.Location = New System.Drawing.Point(320, 272)
        Me.btnSendN.Name = "btnSendN"
        Me.btnSendN.Size = New System.Drawing.Size(112, 32)
        Me.btnSendN.TabIndex = 4
        Me.btnSendN.Text = "Send N"
        '
        'BtnSend
        '
        Me.BtnSend.Location = New System.Drawing.Point(320, 224)
        Me.BtnSend.Name = "BtnSend"
        Me.BtnSend.Size = New System.Drawing.Size(112, 32)
        Me.BtnSend.TabIndex = 5
        Me.BtnSend.Text = "Send"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(16, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(96, 24)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "Channel Name"
        '
        'txtName
        '
        Me.txtName.Location = New System.Drawing.Point(112, 24)
        Me.txtName.Name = "txtName"
        Me.txtName.Size = New System.Drawing.Size(152, 22)
        Me.txtName.TabIndex = 7
        Me.txtName.Text = "MSERVER"
        '
        'MClient
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.ClientSize = New System.Drawing.Size(448, 328)
        Me.Controls.Add(Me.txtName)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.BtnSend)
        Me.Controls.Add(Me.btnSendN)
        Me.Controls.Add(Me.txtTimes)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.txtMSG)
        Me.Controls.Add(Me.Label1)
        Me.Name = "MClient"
        Me.Text = "MClient"
        Me.ResumeLayout(False)

    End Sub

#End Region

    
    Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
        Dim cha1 As MemChannel = New MemChannel(txtName.Text)
        cha1.putMsg(txtMSG.Text)
        cha1.close()


    End Sub

    Private Sub btnSendN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendN.Click
        Dim i As Integer
        Dim oldi As Integer
        Dim wtxt As String
        Dim cha1 As MemChannel = New MemChannel(txtName.Text)
        i = Val(txtTimes.Text)
        oldi = i
        wtxt = txtMSG.Text
        While i > 0
            cha1.putmsgwait(wtxt, 10000)
            i -= 1
            If i Mod 10000 = 0 Then
                txtTimes.Text = i.ToString
                wtxt = txtMSG.Text
                Application.DoEvents()
            End If
        End While
        txtTimes.Text = oldi.ToString
        cha1.close()
    End Sub
End Class
